<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
	<head>
		<s:head theme="ajax" debug="true"/>
		<style>
		    BODY, TD, TH { 
		      font-family: verdana, arial, helvetica, sans-serif;
		      font-size: 12px;
		    }
			ul.simple {
				list-style: none;
			}
		</style>
	</head>
	<body>
		<h2><s:text name="names"/></h2>
		<ol class="simple" id="list">
			<s:iterator value="names">
				<li>
					<s:property/>
				</li>
			</s:iterator>		
		</ol>
		

		<s:url id="smdUrl" namespace="/nodecorate" action="nameList"/>    
		<script type="text/javascript">
		    //load dojo RPC
		    dojo.require("dojo.rpc.*");
		    
		    //create service object(proxy) using SMD (generated by the json result)
		    var service = new dojo.rpc.JsonService("${smdUrl}");
			
			var timer;
		
		   //function called when remote method returns
			var callback = function(bean) {
				var list = document.getElementById("list");
		        for (i=0; i<bean.length; i++) {
					var li = document.createElement("LI");
					var liText = document.createTextNode(bean[i]);
					li.appendChild(liText);
					list.appendChild(li);
		    	}
		    	timer = setTimeout("getNames()", 3000);
		    };
		    
			function getNames() {
			    // execute remote method
				var defered = service.getAllNames();
			    //attach callback to defered object
		    	defered.addCallback(callback);
		    }
		    
		    getNames();
		    
		</script>
		    
		    
		    
		
		

		
	</body>
</html>
